/**
 * 
 */
package com.alphasystem.commerce.common.model.locale;

import static javax.persistence.FetchType.EAGER;
import static javax.persistence.InheritanceType.JOINED;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @author Syed Farhan Ali
 * 
 */
@Entity
@Table(name = "CURRENCY")
@Inheritance(strategy = JOINED)
public class Currency extends LocaleEntity {

	private static final long serialVersionUID = -6056587750837117645L;

	protected Set<Country> countries;

	protected String currencyCode;

	public Currency() {
		this(TEMP_ID, TEMP_ID);
	}

	public Currency(String currencyCode, String name) {
		super(currencyCode);
		this.currencyCode = currencyCode;
		this.name = name;
	}

	@ManyToMany(mappedBy = "currencies", fetch = EAGER)
	public Set<Country> getCountries() {
		return countries;
	}

	@Column(name = "currency_code", length = 3, unique = true, nullable = false)
	public String getCurrencyCode() {
		return currencyCode;
	}

	public void setCountries(Set<Country> countries) {
		this.countries = countries;
	}

	public void setCurrencyCode(String currencyCode) {
		this.currencyCode = currencyCode;
	}

	@Override
	public String toString() {
		return "Currency: " + currencyCode + "-" + name;
	}

}
